export default {
  data() {
    return {
      companyList: [
        {
          value: '选项1',
          label: '黄金糕',
        },
        {
          value: '选项2',
          label: '双皮奶',
        },
      ],
      departmentList: [
        {
          value: '选项1',
          label: '黄金糕',
        },
        {
          value: '选项2',
          label: '双皮奶',
        },
      ],
    };
  },
  methods: {
    // 获取公司列表
    initCompanyList() {},
    // 根据公司code获取部门列表
    getDepartmentListByCompanyCode(companyCode) {},
    // 切换公司,部门
    changeCompanyDepartmentHandler(value, column, type) {
      const { prop, changeMethod } = column;
      let label = '';
      if (type === 'company') {
        label = this.companyList.find((item) => item.value === value)?.label;
        this.getDepartmentListByCompanyCode(value);
      } else if (type === 'department') {
        label = this.companyList.find((item) => item.value === value)?.label;
      }
      if (typeof changeMethod === 'function') {
        changeMethod(val);
      } else {
        this.$emit(changeMethod, { val: value, prop, label });
      }
    },
    // 清除公司,部门
    clearCompanyDepartmentMethod(query, column) {
      const { clearMethod, prop, clearRelation } = column;
      query[prop] = '';
      query[clearRelation] = '';
      if (!clearMethod) {
        return;
      }
      this.$emit(clearMethod, { prop });
    },
  },
};
